package com.yeyks.controller.hotel;


import cn.hutool.core.bean.BeanUtil;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.base.Arguments;
import com.yeyks.common.base.PageResult;
import com.yeyks.hotel.dal.domain.HotelVipShow;
import com.yeyks.hotel.param.HotelVipShowAddParam;
import com.yeyks.hotel.param.HotelVipShowListParam;
import com.yeyks.hotel.param.HotelVipShowUpdateParam;
import com.yeyks.hotel.service.HotelVipShowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 优享vip展示酒店前端控制器
 * </p>
 *
 * @author shuai
 * @since 2020-02-05
 */
@Api(tags = "推荐酒店模块")
@RestController
@RequestMapping("/hotelVipShow")
public class HotelVipShowController {
    @Autowired
    private HotelVipShowService hotelVipShowService;

    @ApiOperation(value = "v4.2 --> 列表", response = HotelVipShow.class)
    @PostMapping(value = "/list")
    public AjaxResponseBody<PageResult<HotelVipShow>> list(HotelVipShowListParam param) {
        PageResult<HotelVipShow> pageResult = hotelVipShowService.myList(param);
        return AjaxResponseBody.success(pageResult);
    }

    @ApiOperation(value = "v4.2 --> 新增", notes = "返回结果中true成功，false失败")
    @PostMapping(value = "/add")
    public AjaxResponseBody<Boolean> add(@Validated HotelVipShowAddParam param) {
        return AjaxResponseBody.success(hotelVipShowService.mySave(param));
    }

    @ApiOperation(value = "v4.2 --> 更新", notes = "返回结果中true成功，false失败")
    @PostMapping(value = "/update")
    public AjaxResponseBody<Boolean> update(@Validated HotelVipShowUpdateParam param) {
        return AjaxResponseBody.success(hotelVipShowService.myUpdate(param));
    }

    @ApiOperation(value = "v4.2 --> 删除", notes = "返回结果中true成功，false失败")
    @PostMapping(value = "/del")
    public AjaxResponseBody<Boolean> del(Integer id) {
        Arguments.intIsNull(id, "id不能为空");
        HotelVipShowUpdateParam param = new HotelVipShowUpdateParam();
        param.setId(id);
        param.setStatus(0);
        return AjaxResponseBody.success(hotelVipShowService.myUpdate(param));
    }
}
